/**
 * @param {ListNode} head
 * @param {number} n
 * @return {ListNode}
 * 一趟扫描实现
 */
function removeNthFromEnd(head, n) {
    const dummy=new ListNode(0,head)
    let slow=dummy,fast=head
    for(let i=0;i<n;i++){
        fast=fast.next
    }
    while(fast){
        slow=slow.next
        fast=fast.next
    }
    slow.next=slow.next.next
    return dummy.next
};
class ListNode{
    constructor(val,next){
        this.val = (val===undefined ? 0 : val)
        this.next = (next===undefined ? null : next)
    }
}